home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_400
/
406_01
/
atoc
/
trigraph.c
< prev
Wrap
Text File
|
1993-11-09
|
1KB
|
46 lines
/*=========================================================================
ATOC trigraph module
=========================================================================*/
#include <stdio.h>
#include "atoc.h"
/*-------------------------------------------------------------------------
trigraph( s ) replaces any trigraphs with their standard equivalents.
-------------------------------------------------------------------------*/
trigraph( s )
char *s;
{
static struct { /* trigraph table */
char *tg; /* trigraph sequence */
char *std; /* standard character */
} table[] = {
{ "??=", "#" },
{ "??(", "[" },
{ "??/", "\\" },
{ "??)", "]" },
{ "??'", "^" },
{ "??<", "{" },
{ "??!", "|" },
{ "??>", "}" },
{ "??-", "~" },
{ NULL, NULL },
};
char *cp, *strstr();
int i;
if ( trigraphflag )
for ( cp = s; ( cp = strstr( cp, "??" ) ) != NULL; ++cp )
for ( i = 0; table[ i ].tg; ++i )
if ( strncmp( cp, table[ i ].tg, 3 ) == 0 )
{
strcpy( cp, cp + 3 );
strins( cp, table[ i ].std );
break;
}
}
/*=======================================================================*/